package com.agv.backend.controller;


import com.agv.backend.entity.AgvMovementResponse;
import com.agv.backend.entity.AgvResponse;
import com.agv.backend.entity.AjaxResult;
import com.agv.backend.entity.vo.AgvStatusVO;
import com.agv.backend.service.AgvMovementService;
import com.agv.backend.service.impl.AgvMovementServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/agv/movement")
public class AgvMovementController {

    private final AgvMovementService agvMovementService;

    public AgvMovementController(AgvMovementService agvMovementService) {
        this.agvMovementService = agvMovementService;
    }

    @GetMapping("heartbeat")
    public AgvStatusVO heartbeat(){
        AgvMovementResponse agvMovementResponse = agvMovementService.getHeartbeat();
        return agvMovementResponse.getData();
    }

    @PostMapping("forward")
    public Boolean agvForward(){
       return agvMovementService.forward();
    }


    @PostMapping("stop")
    public Boolean agvStop(){
        return agvMovementService.stop();
    }


    @PostMapping("backward")
    public Boolean agvBackward(){
        return agvMovementService.backward();
    }

}
